//
//  WATFFTVListCell.swift
//  WiFiFaster
//
//  Created by one on 2024/1/5.
//

import UIKit

class WATFFTVListCell: UICollectionViewCell {
    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView.addSubview(watf_bgView)
        contentView.addSubview(watf_iconView)
        contentView.addSubview(watf_titleLabel)
        contentView.addSubview(watf_selectView)
        watf_bgView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        watf_iconView.snp.makeConstraints { make in
            make.size.equalTo(CGSize(width: 28, height: 28))
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(12)
        }
        watf_titleLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(watf_iconView.snp.right).offset(14)
        }
        watf_selectView.snp.makeConstraints { make in
            make.size.equalTo(20)
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-20)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    var watf_ftvModel: WATFFTVTempModel? {
        didSet {
            guard let watf_ftvModel = watf_ftvModel else { return  }
            if watf_ftvModel.watf_smart {
                watf_titleLabel.text = "smart location"
            }else {
                watf_titleLabel.text = watf_ftvModel.watf_country
            }
           
            watf_selectView.image = UIImage(named: watf_ftvModel.watf_select ? "watf_ftv_select":"watf_ftv_unselect")
            if watf_ftvModel.watf_icon == "" {
                watf_iconView.isHidden = true
                return
            }
            watf_iconView.isHidden = false
            if watf_ftvModel.watf_smart {
                watf_iconView.image = UIImage(named: "watf_ftv_smart")
            }else {
                watf_iconView.image = UIImage(named: watf_ftvModel.watf_icon)
            }
           
        }
    }
    lazy var watf_bgView: UIImageView = {
        let watf_bgView = UIImageView(image: UIImage(named: "watf_result_upCell"))
        return watf_bgView
    }()
    lazy var watf_iconView: UIImageView = {
        let watf_iconView = UIImageView(image: UIImage(named: "watf_ftv_listIcon1"))
        return watf_iconView
    }()
    lazy var watf_titleLabel: UILabel = {
        let watf_titleLabel = UILabel()
        watf_titleLabel.font = UIFont.systemFont(ofSize: 14)
        watf_titleLabel.textColor = WATFCommon.watf_getHXColorValue(rgb: 0xFFFFFF)
        watf_titleLabel.text = "Britain"
        return watf_titleLabel
    }()
    lazy var watf_selectView: UIImageView = {
        let watf_selectView = UIImageView(image: UIImage(named: "watf_ftv_unselect"))
        return watf_selectView
    }()
}
